package com.situ.springboot.controller;

import com.situ.springboot.pojo.Student;
import com.situ.springboot.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;
import java.util.Map;

@Controller
public class StuController {
    @Autowired
    StuService service;

    @GetMapping("show")
    public String queryall(Map map) {
        List<Student> list = service.queryall();
        map.put("list", list);
        return "index.html";
    }

    @GetMapping("stu-update1")
    public String update1(Map map, int id) {
        Student Stu = service.queryallByid(id);
        map.put("stu", Stu);
        return "show.html";
    }
    @PostMapping("update2")
    public String update2(Map map, Student student) {
          service.update(student);

        return "show";
    }
}